"""
这是添加商机页面类
"""
#引入基类
from framwork.pages.base_page import BasePage
#引入by方法
from selenium.webdriver.common.by import By

class AddOpportunityPage(BasePage):
    """先写定位器，再写方法"""
    sj_name_locator = (By.CSS_SELECTOR, "#name")
    estimate_price_locator = (By.ID, "estimate_price")  # 预计成交价
    save_btn_locator = (By.CSS_SELECTOR, "#form1 > table > tfoot > tr > td > input:nth-child(1)")
    customer_name_locator = (By.ID, "customer_name")
    customer_kh_locator = (By.NAME, "customer")
    accept_locator = (By.XPATH, "//span[text()='确认']")
    save_btn_locator = (By.CSS_SELECTOR, "#form1 > table > tfoot > tr > td > input:nth-child(1)")

    def input_sj_name(self, sj_name):
        """输入商机名"""
        self.find_element(self.sj_name_locator).send_keys(sj_name)

    def input_price(self, estimate_price):
        """输入预计成交价"""
        self.find_element(self.estimate_price_locator).send_keys(estimate_price)
    def click_customer_name(self):
        """点击客户输入框"""
        self.find_element(self.customer_name_locator).click()

    def choose_customer(self):
        """浮动层弹窗选择客户"""
        self.find_element(self.customer_kh_locator).click()

    def click_accept(self):
        """点击确认"""
        self.find_element(self.accept_locator).click()

    def click_save_btn(self):
        """点击保存按钮"""
        self.find_element(self.save_btn_locator).click()

